package xuanzhen.pro.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import xuanzhen.pro.dao.CofeMapper;
import xuanzhen.pro.pojo.CofeGain;
import xuanzhen.pro.service.CofeService;
@Service
public class CofeServiceImpl implements CofeService {
	@Resource
	CofeMapper cofeMapper;
	@Override
	public CofeGain saveCofeGain(CofeGain cg) throws Exception {
		cg.setGainState("none");
		cofeMapper.add(cg);
		CofeGain cofe=cofeMapper.selectCofeGain(cg.getOpenid());
		return cofe;
	}
	@Override
	public CofeGain selectCofeGain(String openid) throws Exception {
		CofeGain cofe=cofeMapper.selectCofeGain(openid);
		return cofe;
	}
	@Override
	public CofeGain updateCofeGain(CofeGain cg) throws Exception {
		
		cofeMapper.update(cg);
		CofeGain cofe=cofeMapper.selectCofeGain(cg.getOpenid());
		return cofe;
	}

}
